package tools

import (
	"fmt"
	"time"
)

func Dcm4cheDateTimeDecode(dateStr, timeStr string) (t1 time.Time, err error) {
	loc, _ := time.LoadLocation("Asia/Shanghai")
	t1, err = time.ParseInLocation("20060102-150405", fmt.Sprintf("%s-%s", dateStr, timeStr), loc)
	return t1, err
}

func TimeEncodeNow() int64 {
	//return time.Now().Format(time.RFC3339)
	return time.Now().Unix()
}

func TimeEncode(t time.Time) int64 {
	return t.Unix()
}

func TimeEncodeString(ts string) int64 {
	t, _ := time.Parse(time.RFC3339, ts)
	return t.Unix()
}

func TimeDecode(t int64) time.Time {

	return time.Unix(t, 0)
	//return time.Parse(time.Unix(t,0), t)
}
